layui.use(['jquery', 'element', 'layer', 'form', 'layedit'], function(){
    var $ = layui.$;
    var layedit = layui.layedit;
    var form = layui.form;
    var ctxPath = "/education";

    /**
     * 详情富文本
     */
   /* var detailEditId = layedit.build('detail', {
        height: 500,
        uploadImage :  {
            url: ctxPath + '/file/uploadPic',
            type: 'post',
        }
    });*/
    var id = window.location.search.substring(4)
    /**
     * 初始化游学产品详情方法
     * @param id
     */
    var initStudyToursProduct = function(id) {
        $.ajax({
            url: ctxPath + '/api/order/findById',
            type: 'post',
            dataType: 'json',
            data: {id: id},
            success: function (result) {
                if(result.code == 0) {
                    var data = result.data;
                    if (data != null) {
                        $("input[name='id']").val(data.id);
                        $("input[name='orderCode']").val(data.orderCode);
                        if(0==data.productType) {
                            $("input[name='productType']").val("游学");
                        }else if(1==data.productType) {
                            $("input[name='productType']").val("留学");
                        }else {
                            $("input[name='productType']").val("其他");
                        }
                        $("input[name='productName']").val(data.productName);
                        $("input[name='productCode']").val(data.productCode);
                        $("input[name='productDeposit']").val(data.productDeposit);
                        $("input[name='applicantName']").val(data.applicantName);
                        $("input[name='groupName']").val(data.groupName);
                        $("input[name='age']").val(data.age);
                        $("input[name='phone']").val(data.phone);
                        $("input[name='email']").val(data.email);
                        $("input[name='school']").val(data.school);
                        $("input[name='grade']").val(data.grade);
                        $("input[name='address']").val(data.address);
                        $("input[name='remarks']").val(data.remarks);
                        $("#previewImg").attr("src", data.previewImg);
                    }
                } else {
                    layer.alert("get data fail：" + result.msg);
                }
            }
        });
    }

    /**
     * 初始化游学产品
     * @type {string}
     */
    initStudyToursProduct(id);

    $("#cancelBtn").click(function () {
        location.href = ctxPath + '/html/productOrder/productOrderList.html';
    })

});

